package leetcode_interview;

import java.util.Arrays;

public class I0102 {
    public static void main(String[] args) {
        I0102 i0102 = new I0102();
        i0102.CheckPermutation("cuhv", "cuvs");
    }

    public boolean CheckPermutation(String s1, String s2) {
        int[] dict = new int[26];
        if (s1.length() != s2.length())
            return false;
        int n = s1.length();
        for (int i = 0; i < n; i++) {
            int s1Index = s1.charAt(i) - 'a';
            int s2Index = s2.charAt(i) - 'a';
            dict[s1Index] += 1;
            dict[s2Index] -= 1;
        }
        for (int i = 0; i < 26; i++) {
            if (dict[i] != 0)
                return false;
        }
        return true;
    }
}
